package interator;

import java.util.Arrays;
import java.util.Iterator;
import java.util.List;
import java.util.ListIterator;

public class IteratorTest {
	public static void main(String[] args) {
		List<Integer> list = Arrays.asList(1,2,3,4,5,6);
		Iterator<Integer> it = list.iterator();
		while(it.hasNext()){
			Object obj = it.next();
			System.out.print(obj+" ");
		}
		System.out.println();
		System.out.println("------------------");
		ListIterator<Integer> it2 = list.listIterator();
		while(it2.hasNext()){
			Object obj = it2.next();
			System.out.print(obj+" ");
		}
		System.out.println();
		System.out.println("------------------");
		while(it2.hasPrevious()){
			Object obj = it2.previous();
			System.out.print(obj+" ");
		}
	}
}
